enable_testing()

add_subdirectory(helpers)

function(http_layer_test test_name)
	set(TEST_EXECUTABLE run_${test_name})
	set(TEST_SOURCE ${test_name}.cc)
	add_executable(${TEST_EXECUTABLE} ${TEST_SOURCE})
	target_include_directories(${TEST_EXECUTABLE} PRIVATE
		${PROJECT_SOURCE_DIR}/../include
		$<TARGET_PROPERTY:http_layer_libevent_internal,INTERFACE_INCLUDE_DIRECTORIES>
	)
	target_link_libraries(${TEST_EXECUTABLE} PRIVATE
		HttpLayer
		http_layer_gtest_internal
		http_layer_libevent_internal
		http_layer_openssl_internal
		http_layer_curl_internal
		tests_helpers
	)

	if (UNIX AND NOT WIN32)
		target_link_libraries(${TEST_EXECUTABLE} PRIVATE dl)
	else ()
		target_link_libraries(${TEST_EXECUTABLE} PRIVATE Ws2_32.lib Iphlpapi.lib Mswsock.lib)
	endif ()

	add_test(NAME ${test_name} COMMAND ${TEST_EXECUTABLE})
endfunction()

http_layer_test(async_test)
http_layer_test(https_server_test)
http_layer_test(cookie_test_2)
http_layer_test(endpoint_initialization_test)
http_layer_test(headers_test)
http_layer_test(helpers_test)
http_layer_test(http_client_test)
http_layer_test(http_parsing_test)
http_layer_test(http_server_test)
http_layer_test(log_api_test)
http_layer_test(string_logger_test)
http_layer_test(uri_test)